package com.wzz.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author DarkClown
 * @date 2024-08-05 09:23
 * @project_name day0805-week3
 * @parem
 **/
@Configuration
public class MyGlobalFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();

        String s = request.getRemoteAddress().toString();

        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
